/**
  Implementation of CICM backend.
  @todo Complete the source code to operate with a specific cryptographic device.
  @file cicm.cpp
  @version 0.1
  @date 2011-03-04
*/

#include "cicm.h"
#include <iostream>
using namespace CICM;

/**
 @todo Constructor for Buffer (IDL sequence<octet>).
*/
CICM::Buffer::Buffer(unsigned long len, char *data) {};

/**
  @todo Destructor for Buffer (IDL sequence<octet>).
*/
CICM::Buffer::~Buffer() {};

/**
  @todo Override equality operator.
*/
bool CICM::Buffer::operator==(const Buffer &other) const { return false; };

/**
  @todo Return a reference to the module with the given module unique identifier.
  @class CICMRoot
  @param [in]  module_id
  @param [out] crypto_module_ref
  @return status code
  @see http://tools.ietf.org/html/draft-lanz-cicm-02#section-2.3.1.1
*/
Status CICMRoot::get_module_by_id(
  ModuleId& module_id,              /* in */
  CryptoModule** crypto_module_ref  /* out */
) { return S_OK; };

/**
  @todo Return a reference to CICM::SymKeyManager.
  @class CryptoModule
  @return a reference to the symmetric key manager
  @see http://tools.ietf.org/html/draft-lanz-cicm-02#section-2.3.2.1
*/
SymKeyManager* CryptoModule::_get_sym_key_manager(void) {
  return &(this->sym_key_manager);
};

/**
  @todo Return a reference to CICM::ChannelManager.
  @class CryptoModule
  @return a reference to the channel manager
  @see http://tools.ietf.org/html/draft-lanz-cicm-02#section-2.3.2.1
*/
ChannelManager* CryptoModule::_get_channel_manager(void) {
  return &(this->channel_manager);
};

/**
  @todo Return a reference to the symmetric key corresponding
    to the specified infrastructure-specific identifier.
  @class SymKeyManager
  @param [in]  key_id
  @param [out] key_ref
  @return status code
  @see http://tools.ietf.org/html/draft-lanz-cicm-km-00#section-5.1.2
*/
Status SymKeyManager::get_key_by_id(
  KeyId& key_id,    /* in */
  SymKey** key_ref  /* out */
){ return S_OK; };

/**
  @todo Create conduit to encrypt a stream of data.
  @class Encrypt::ChannelManager
  @param [in]  remote_port
  @param [in]  key_ref
  @param [in]  algorithm
  @param [out] conduit_ref
  @return status code
  @see http://tools.ietf.org/html/draft-lanz-cicm-cm-00#section-9.1.1
*/
Status Encrypt::ChannelManager::create_encrypt_conduit(
  RemotePort& remote_port,        /* in */
  SymKey* key_ref,                /* in */
  SymEncrAlgorithmId& algorithm,  /* in */
  Encrypt::Conduit** conduit_ref  /* out */
) { return S_OK; }

/**
  @todo Sends data to the module to be encrypted.
    The method blocks until data is sent.
  @class Encrypt::Stream
  @param [in] buffer
  @return status code
  @see http://tools.ietf.org/html/draft-lanz-cicm-cm-00#section-9.2.2
*/
Status Encrypt::Stream::encrypt(
  Buffer*& buffer /* in */
) { return S_OK; }

/**
  @todo Create conduit to decrypt a stream of data.
  @class Decrypt::ChannelManager
  @param [in]  remote_port
  @param [in]  key_ref
  @param [in]  algorithm
  @param [out] conduit_ref
  @return status code
  @see http://tools.ietf.org/html/draft-lanz-cicm-cm-00#section-10.1.1
*/
Status Decrypt::ChannelManager::create_decrypt_conduit(
  RemotePort& remote_port,        /* in */
  SymKey* key_ref,                /* in */
  SymEncrAlgorithmId& algorithm,  /* in */
  Decrypt::Conduit** conduit_ref  /* out */
) { return S_OK; }

/**
  @todo  Read plaintext data off of decrypt channel stream.
    The method blocks until data becomes available.
  @class Encrypt::Stream
  @param [out] buffer
  @return status code
  @see http://tools.ietf.org/html/draft-lanz-cicm-cm-00#section-10.2.2
*/
Status Decrypt::Stream::decrypt(
  Buffer** buffer /* out */
) { return S_OK; }


